Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Adding a dynamic menu to the test window
In this section, you’ll add a dynamic menu to the test window. The menu displays all SalesReps and lets the user filter the list of Customers by a selected SalesRep. This example demonstrates one typical use of dynamic menus—to create a list of menu items that are data-driven. In other cases, a list of dynamic menu items might be based on currently available windows or other elements of an application that can vary at run time.
![]()
To add a dynamic menu bar to the h-CustOrderWin7.w procedure:
- Add a new fill-in field to the window to display the selected SalesRep. Name it cSalesRep.
- Create a new internal procedure called
createMenu. The procedure needs handle variables for the menu bar, its submenu, and one handle for all the menu items you create:
- Create the menu bar and its submenu:
- Create the list of SalesReps as menu items:
Each one is parented to the submenu. You can reuse the same object handle for each one because you won’t need to reference those objects individually. Each menu item has the SalesRep initials followed by the SalesRep’s full name as its label.
When the user chooses one of these items, you want to reopen the Customer query for just Customers of that SalesRep. Remember that when you define a trigger on an object inside an internal procedure or another trigger block, the trigger definition doesn’t persist beyond the end of that procedure or block. Therefore, you have to use the special
PERSISTENT RUNstatement to tell Progress to run a separate procedure when the event occurs. You’ll write thisfilterCustprocedure in a moment.- Add a couple of special menu items to the end of the list. Create a
RULEto separate the SalesReps from the final menu item:
- Add a menu item that closes the window and its procedure:
Once again, the trigger code has to be in a separate procedure.
- Parent the menu bar to the window:
- Create the
filterCustprocedure for the SalesRep items:
This code reopens the Customer query for just those Customers whose initials match the first part of the menu item label. Remember that the built-in handle
SELFalways evaluates to the object handle that triggered the event.The procedure displays the selected SalesRep in the new fill-in field, and then resyncs the display to the first record in the new query by programmatically clicking the First button.
- Define the internal procedure
leaveProcto handle the Exit button:
This code simply invokes the
CLOSEevent already defined as a standard part of the AppBuilder-generated code for the window.- Add a statement to the procedure’s main block to run
createMenu:
- Run the procedure again. Now you can drop down a list of all the SalesReps:
![]()
- Select one. Now Customers are selected for that SalesRep only:
![]()
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |